$.extend({
    exist: function(obj) {
        if ($(obj).length > 0) {
            return true;
        } else {
            return false;
        }
    }
});

//判断是否是数字

$.extend({
    is_number: function(s) {
        if (s != null && s != "") {
            return !isNaN(s);
        }
        return false;
    }
});


//弹出层-jquery-拓展

$.extend({
    show_window: function(html, cla, mode) {
        var box_html = ['<div class="show_window">',
            '  <div class="cover"></div>',
            '  <div class="code">',
            '    <div class="tl cx">',
            '      <div class="close fr">',
            '        <span class="iconfont icon-jcuo2"></span>',
            '      </div>',
            '    </div>',
            '    <div class="con">',
            '    </div>',
            '  </div>',
            '</div>'
        ].join("");

        mode == undefined ? 0 : mode;


        if (mode == 'hide' && $('.show_window.' + cla).length > 0) {
            var box = $('.show_window.' + cla);
            box.removeClass('d_n');
        } else {
            var box = $(box_html).appendTo($('body'));
        }

        var code = box.find('.code');
        var cover = box.find('.cover');
        var close = box.find('.close');
        var con = code.children('.con');
        if (cla != undefined) {
            box.addClass(cla);
        }

        con.append(html);

        box.show();

        close.click(function() {
            box.addClass('d_n');
            if (mode == 'hide') {
                return false;
            }
            setTimeout(function() {
                box.remove();
            }, 100);
        });

        return box;
    }
});



//倒计时组件


$.extend({
    log: function(obj) {
        console.log(obj);
    }
});


$.extend({
    check_input: function(input) {
        var val = input.val();
        var tip = '<div class=tip>必填</div>';
        if (val == '') {
            input.css('border-color', '#ff8080').attr('ok', 'no');
            input.next('.tip').remove();
            $(tip).css({
                'position': 'absolute',
                'right': '10px',
                'display': 'block',
                'top': '12px',
                'color': '#ff8080'
            }).insertAfter(input).parent().addClass('relative');
            input.keydown(function(event) {
                input.next('.tip').remove();
                input.css('border-color', '#e6e6e6');
            });
            input.blur(function(event) {
                input.next('.tip').remove();
                input.css('border-color', '#e6e6e6');
            });
            return false;
        } else {
            input.attr('ok', 'yes');
            return true;
        }
    }
});

$.extend({
    CountDownP: function(phone, btn, count, url) {
        var InterValObj; //timer变量，控制时间
        var curCount; //当前剩余秒数
        var code = ""; //验证码
        var codeLength = 6; //验证码长度

        function SetRemainTime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj); //停止计时器
                btn.attr("isok", "ok"); //启用按钮
                btn.css('background-color', '#83c0eb').css('cursor', 'pointer');
                btn.val("重新发送");
                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
            } else {
                curCount--;
                btn.val(+curCount + "秒再获取");
            }
        }

        function sendMessage() {
            curCount = count;
            var dealType; //验证方式
            var phone_val = phone.val();
            //向后台发送处理数据
            $.ajax({
                type: "GET",
                url: url,
                data: "phone=" + phone_val,
                dataType: "text",
                success: function(msg) {
                    //设置button效果，开始计时
                    msg = $.trim(msg);
                    if (msg == 'true') {
                        btn.attr("isok", "no");
                        btn.css('background-color', '#dbdbdb').css('cursor', 'default');
                        btn.val(+curCount + "秒再获取");
                        InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                    } else {

                        tip_fan('服务器繁忙，请稍后再试');
                    }

                }
            });
        }
        if (btn.attr('isok') == 'ok') {
            sendMessage();
        }
    }
});


$.extend({
    CountDown: function(phone, btn, count, url) {
        var InterValObj; //timer变量，控制时间
        var curCount; //当前剩余秒数
        var code = ""; //验证码
        var codeLength = 6; //验证码长度

        function SetRemainTime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj); //停止计时器
                btn.attr("isok", "ok"); //启用按钮
                btn.css('background-color', '#83c0eb').css('cursor', 'pointer');
                btn.val("重新发送");
                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
            } else {
                curCount--;
                btn.val(+curCount + "秒再获取");
            }
        }

        function sendMessage() {
            curCount = count;
            var dealType; //验证方式
            var phone_val = phone.val();
            //向后台发送处理数据
            $.ajax({
                type: "GET",
                url: url,
                data: "phone=" + phone_val,
                dataType: "text",
                success: function(msg) {
                    if (msg == 'false') {
                        tip_fan('该手机号已注册');
                    } else {
                        //设置button效果，开始计时
                        btn.attr("isok", "no");
                        btn.css('background-color', '#dbdbdb').css('cursor', 'default');
                        btn.val(+curCount + "秒再获取");
                        InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                    }
                }
            });
        }
        if (btn.attr('isok') == 'ok') {
            sendMessage();
        }
    }
});

$.extend({
    CountDownF: function(phone, btn, count, url) {
        var InterValObj; //timer变量，控制时间
        var curCount; //当前剩余秒数
        var code = ""; //验证码
        var codeLength = 6; //验证码长度

        function SetRemainTime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj); //停止计时器
                btn.attr("isok", "ok"); //启用按钮
                btn.css('background-color', '#83c0eb').css('cursor', 'pointer');
                btn.val("重新发送");
                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
            } else {
                curCount--;
                btn.val(+curCount + "秒再获取");
            }
        }

        function sendMessage() {
            curCount = count;
            var dealType; //验证方式
            var phone_val = phone.val();
            //向后台发送处理数据
            $.ajax({
                type: "GET",
                url: url,
                data: "phone=" + phone_val,
                dataType: "text",
                success: function(msg) {
                    if (msg == 'false') {
                        tip_fan('该手机号未注册');
                    } else {
                        //设置button效果，开始计时
                        btn.attr("isok", "no");
                        btn.css('background-color', '#dbdbdb').css('cursor', 'default');
                        btn.val(+curCount + "秒再获取");
                        InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                    }
                }
            });
        }
        if (btn.attr('isok') == 'ok') {
            sendMessage();
        }
    }
});

$.extend({
    CountDownTrade: function(phone, btn, count, url) {
        var InterValObj; //timer变量，控制时间
        var curCount; //当前剩余秒数
        var code = ""; //验证码
        var codeLength = 6; //验证码长度

        function SetRemainTime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj); //停止计时器
                btn.attr("isok", "ok"); //启用按钮
                btn.css('background-color', '#83c0eb').css('cursor', 'pointer');
                btn.val("重新发送");
                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
            } else {
                curCount--;
                btn.val(+curCount + "秒再获取");
            }
        }

        function sendMessage() {
            curCount = count;
            var dealType; //验证方式
            var phone_val = phone.val();
            //向后台发送处理数据
            $.ajax({
                type: "GET",
                url: url,
                data: "phone=" + phone_val,
                dataType: "text",
                success: function(msg) {
                    if (msg == 'false') {
                        tip_fan('未知错误,请重试');
                    } else {
                        //设置button效果，开始计时
                        btn.attr("isok", "no");
                        btn.css('background-color', '#dbdbdb').css('cursor', 'default');
                        btn.val(+curCount + "秒再获取");
                        InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                    }
                }
            });
        }
        if (btn.attr('isok') == 'ok') {
            sendMessage();
        }
    }
});


//以POST表单方式打开新窗口的JQUERY实现 
$.extend({
    StandardPost: function(url, args) {
        var body = $(document.body),
            form = $("<form method='post'></form>"),
            input;
        form.attr({
            "action": url
        });
        $.each(args, function(key, value) {
            input = $("<input type='hidden'>");
            input.attr({
                "name": key
            });
            input.val(value);
            form.append(input);
        });

        form.appendTo(document.body);
        form.submit();
        document.body.removeChild(form[0]);
    }
});

$.extend({
    tip_fan: function(str) {
        $('#mydiv.tip_fan').remove();
        $('#cover_tip_fan').remove();
        var successDiv = $('<div>', {
            'id': 'mydiv',
            'class': 'tip_fan'
        });

        var cover = $('<div>', {
            'id': 'cover_tip_fan',
            'class': 'cover_tip_fan'
        });

        cover.css({
            'background': '#000',
            'width': '100%',
            'height': '100%',
            'position': 'fixed',
            'z-index': '100000002',
            'top': '0',
            'left': '0',
            'opacity': '0.5'
        });
        var str_len = str.length;

        var width = 150 + str_len * 12;


        var win_h = $(window).height() - 30;
        successDiv.append('<span class="button_close"/>');
        successDiv.append('<span/>').append(str).css({
            'background': '#fff',
            'color': '#666',
            'border': '1px solid #e3e3e3',
            'box-shadow': '0 1px 6px rgba(0, 0, 0, 0.1)',
            'position': 'fixed',
            'z-index': '100000003',
            'top': win_h / 2,
            'left': '50%',
            'width': width + 'px',
            'padding': '20px 10px',
            'height': '30px',
            'line-height': '30px',
            'font-size': '16px',
            'border-radius': '3px',
            'margin-left': '-135px',
            'margin-top': '-50px',
            'text-align': 'center'
        });

        successDiv.find('span.button_close').click(function() {
            successDiv.stop().remove();
            cover.stop().remove();
        });

        cover.appendTo('body').hide().fadeIn().delay(900).fadeOut(
            function() {
                $(this).remove();
            }
        );
        successDiv.appendTo('body').hide().fadeIn().delay(900).fadeOut(
            function() {
                $(this).remove();
            }
        );
    }
});



//对象打印支持函数

function writeObj(obj) {
    var description = "";
    for (var i in obj) {
        var property = obj[i];
        description += i + " = " + property + "\n";
    }
    alert(description);
}



function tip_fan(str) {
    var successDiv = $('<div>', {
        'id': 'mydiv',
        'class': 'tip_fan'
    });
    var win_h = $(window).height() - 30;
    successDiv.append('<span/>').append(str).css({
        'background': '#fff',
        'color': '#666',
        'border': '2px solid #f0f0f0',
        'box-shadow': '0 1px 6px rgba(0, 0, 0, 0.1)',
        'position': 'fixed',
        'z-index': '100000003',
        'top': win_h / 2,
        'left': '50%',
        'width': '250px',
        'padding': '20px 10px',
        'height': '30px',
        'line-height': '30px',
        'font-size': '16px',
        'border-radius': '3px',
        'margin-left': '-135px',
        'margin-top': '-50px',
        'text-align': 'center'
    })
    successDiv.appendTo('body').hide().fadeIn().delay(1000).fadeOut(
        function() {
            $(this).remove();
        }
    );
}

function tip_suc(str) {
    var successDiv = $('<div>', {
        'id': 'mydiv',
        'class': 'tip_suc'
    });
    var win_h = $(window).height() - 30;
    successDiv.append('<span/>').append(str).css({
        'background': '#fff',
        'color': '#666',
        'border': '2px solid #f0f0f0',
        'box-shadow': '0 1px 6px rgba(0, 0, 0, 0.1)',
        'position': 'fixed',
        'z-index': '100000003',
        'top': win_h / 2,
        'left': '50%',
        'width': '170px',
        'padding': '20px 10px',
        'height': '30px',
        'line-height': '30px',
        'font-size': '16px',
        'border-radius': '3px',
        'margin-left': '-95px',
        'margin-top': '-50px',
        'text-align': 'center'
    });
    successDiv.append('<span class="button_close"></span>');
    successDiv.find('span.button_close').click(function() {
        successDiv.stop().remove();
    });
    successDiv.appendTo('body').hide().fadeIn().delay(1000).fadeOut(
        function() {
            $(this).remove();
        }
    );
}

function tip_suc2(str) {
    var successDiv = $('<div>', {
        'id': 'mydiv',
        'class': 'tip_suc'
    });
    var win_h = $(window).height() - 30;
    successDiv.append('<span/>').append(str).css({
        'background': '#fff',
        'color': '#666',
        'border': '2px solid #f0f0f0',
        'box-shadow': '0 1px 6px rgba(0, 0, 0, 0.1)',
        'position': 'fixed',
        'z-index': '100000003',
        'top': win_h / 2,
        'left': '50%',
        'width': '170px',
        'padding': '20px 10px',
        'height': '30px',
        'line-height': '30px',
        'font-size': '16px',
        'border-radius': '3px',
        'margin-left': '-95px',
        'margin-top': '-50px',
        'text-align': 'center'
    })
    successDiv.appendTo('body').hide().fadeIn().delay(2000).fadeOut(
        function() {
            $(this).remove();
        }
    );
}

function tip_suc3(str) {
    var successDiv = $('<div>', {
        'id': 'mydiv',
        'class': 'tip_suc'
    });
    var win_h = $(window).height() - 30;
    successDiv.append('<span/>').append(str).css({
        'background': '#fff',
        'color': '#666',
        'border': '2px solid #f0f0f0',
        'box-shadow': '0 1px 6px rgba(0, 0, 0, 0.1)',
        'position': 'fixed',
        'z-index': '100000003',
        'top': win_h / 2,
        'left': '50%',
        'width': '270px',
        'padding': '20px 10px',
        'height': '30px',
        'line-height': '30px',
        'font-size': '16px',
        'border-radius': '3px',
        'margin-left': '-135px',
        'margin-top': '-50px',
        'text-align': 'center'
    })
    successDiv.appendTo('body').hide().fadeIn().delay(2000).fadeOut(
        function() {
            $(this).remove();
        }
    );
}

jQuery.fn.checkPhone = function() { // 自定义jQuery方法
    var phone_val = $(this).val();
    reg = /^1[3|4|5|7|8]\d{9}$/;
    if (!reg.test(phone_val)) {
        return true; // 格式有误
    } else {
        return false;
    }
}


$.checkPhone = function(str) { // 自定义jQuery方法
    var phone_val = str;
    reg = /^1[3|4|5|7|8]\d{9}$/;
    if (!reg.test(phone_val)) {
        return true; // 格式有误
    } else {
        return false;
    }
}



function slide_hover(anniu, jiantou, neirong) {

    anniu.hover(function() {
        jiantou.addClass('trans_effect');
        neirong.removeClass('d_n');
        if (jiantou.hasClass('trans_effect_out')) {
            jiantou.removeClass('trans_effect_out');
        }
    }, function() {
        jiantou.removeClass('trans_effect').addClass('trans_effect_out');
        neirong.addClass('d_n');
    });
}

//城市

(function() {
    var city_jiantou = $('.city .icon-jiantou-down');
    var city_zhichi = $('.city .city_zhichi');
    var city = $('.city');
    slide_hover(city, city_jiantou, city_zhichi);
    var city_item = $('.city .city_zhichi li.fl');
    city_item.each(function() {
        if ($(this).hasClass('current')) {
            $(this).find('a').css('cursor', 'default');
        } else {
            $(this).find('a').click(function() {
                var data = $(this).attr('data');
                $.post('index.php?r=api/cityChange', {
                    city: data
                }, function(back) {
                    if (back == 'true') {
                        history.go(0);
                    }
                })
            });
        }

    })
})();



(function() {
    //网站导航
    var link_jiantou = $('.link_dh .icon-jiantou-down');
    var link_zhichi = $('.link_dh .link_dh_zhichi');
    var link_dh = $('.link_dh');
    slide_hover(link_dh, link_jiantou, link_zhichi);

    if (link_dh.width() > 140) {
        link_zhichi.width(link_dh.width() - 19);
    }


})();


//登录成功后显示的用户信息
var us_jiantou = $('.us_dh .icon-jiantou-down');
var us_zhichi = $('.us_dh .us_dh_zhichi');
var us_dh = $('.us_dh');
slide_hover(us_dh, us_jiantou, us_zhichi);



$('.search .button').hover(function() {
    $('.search .iconfont').addClass('on');
}, function() {
    $('.search .iconfont').removeClass('on');
});



//tab-over

function tab_over($menu, $content) {
    var $menu;
    var $content;
    var $count_menu = $menu.size();

    function turn_over($con) {
        $con.mouseover(function() {
            $(this).addClass('on').siblings().removeClass('on');
        }).eq(0).mouseover();
    }

    function mouse_turn(i) {
        $menu.eq(i).mouseover(function() {
            $content.eq(i).show().siblings().hide();
            $content.eq(i).removeClass('d_n').siblings().addClass('d_n');
        });
    }

    for (var i = 0; i < $count_menu; i++) {
        mouse_turn(i);
    }
    $menu.eq(0).mouseover();
    turn_over($menu);
}



//tab-click

function tab_click($menu, $content) {
    var $menu;
    var $content;
    var $count_menu = $menu.size();

    function turn_click($con) {
        $con.click(function() {
            $(this).addClass('on').siblings().removeClass('on');
        }).eq(0).click();
    }

    function mouse_turn(i) {
        $menu.eq(i).click(function() {
            $content.eq(i).removeClass('d_n').siblings().addClass('d_n');
        });
    }

    for (var i = 0; i < $count_menu; i++) {
        mouse_turn(i);
    }
    $menu.eq(0).click();
    turn_click($menu);
}

$.extend({
    scroll_to: function(id, num) {
        if (num === undefined) {
            var num = 100;
        }
        $("html,body").stop(true);
        $("html,body").animate({
            scrollTop: $("#" + id).offset().top - num
        }, 50);
    }
});


//滚动到指定id

function scroll_to(id) {
    $("html,body").stop(true);
    $("html,body").animate({
        scrollTop: $("#" + id).offset().top - 46
    }, 50);
}

//滚动到指定元素；

function scroll_to_ele(ele) {
    $("html,body").stop(true);
    $("html,body").animate({
        scrollTop: ele.offset().top - 46
    }, 100);
}


//弹出层

function show_window($con) {
    $con.css('display', 'block');
    var hk_code = $con.find('.code');
    var hk_close = $con.find('.button_close');
    var hk_cover = $con.find('.cover');
    hk_cover.show();
    hk_code.show();
    hk_close.click(function() {
        hk_code.hide();
        hk_cover.hide();
        $con.css('display', 'none');
    });
    hk_cover.click(function() {
        //hk_code.hide();
        //hk_cover.hide();
        //$con.css('display','none');
    })
}

//当连续进行多个请求，并且请求的url地址相同时。放弃前面的所有请求，只执行最后一次请求。

var pendingRequests = {};
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
    var key = options.url;
    //console.log(key);
    if (!pendingRequests[key]) {
        pendingRequests[key] = jqXHR;
    } else {
        jqXHR.abort(); //放弃后触发的提交
        //pendingRequests[key].abort(); // 放弃先触发的提交
    }

    var complete = options.complete;
    options.complete = function(jqXHR, textStatus) {
        pendingRequests[key] = null;
        if ($.isFunction(complete)) {
            complete.apply(this, arguments);
        }
    };
});


// 鼠标经过服务类别，显示具体项目

(function() {
    //$('.all_type_button').css('background', '#fff').css('position', 'relative').css('top', '2px').css('height', '50px').css('line-height', '50px').css('color', '#666').css('border-left', '1px solid #e5e5e5').css('border-right', '1px solid #e5e5e5');
    //$('.all_type_button').css('visibility', 'visible');
    //$('.all_type_info').find('.menu').css('box-shadow', '1px 2px 3px rgba(0, 0, 0, 0.15)').css('border-top', '1px solid #e5e5e5');
    //$('.all_type_info').css('border', '1px solid #e5e5e5');
    //$('.all_type_button').find('span').css('color', '#666');
    //$('.all_type_info').addClass('d_n').css('top', '199px');
    var obj = $('.banner_left');
    var item = obj.find('.menu>ul>.item');
    $('.all_type_button').hover(
        function() {
            $('.all_type_info').removeClass('d_n');
            item.eq(0).mouseover();
        },
        function() {
            $('.all_type_info').addClass('d_n');
        }
    );

    $('.all_type_info').hover(function() {
        $(this).removeClass('d_n');
    }, function() {
        $(this).addClass('d_n');
    });
})();



//服务分类-数据初始化

(function() {
    var obj = $('.banner_left');
    var info = obj.find('.info_wrap>.info')
    var info_item_html = info.html();
    var info_html = '';
    var menu_item = obj.find('.menu>ul>.item');
    menu_item.each(function() {
        info_html += info_item_html;
    });
    info.html(info_html);

    var info_item = info.children('.item');
    info_item.each(function() {
        var second_wrap = $(this).children('ul.txt');
        var ind = $(this).index();
        var second_item_html = second_wrap.html();
        var second_item = menu_item.eq(ind).find('.second>.item');
        var second_html = '';
        var img_wrap = $(this).children('ul.img');
        var img_html = menu_item.eq(ind).children('ul.img').html();
        img_wrap.html(img_html);
        second_item.each(function() {
            second_html += second_item_html;
        });
        second_wrap.html(second_html);

        second_wrap.children('li').each(function() {
            var ind = $(this).index();
            var L_html = second_item.eq(ind).children('.main').html();
            var R_html = second_item.eq(ind).children('.third').html();
            $(this).find('.L').html(L_html);
            $(this).find('.R').html(R_html);
        });
    });



})();


//服务-分类

(function() {
    var obj = $('.banner_left');
    var item = obj.find('.menu>ul>.item');
    var info = obj.find('.info>.item');
    var info_wrap = obj.find('.info_wrap');
    var menu = obj.find('.menu');
    obj.hover(function() {
        info_wrap.removeClass('d_n').animate({
            width: '620px'
        }, 200);
    }, function() {
        info_wrap.stop().css({
            width: '0'
        }).addClass('d_n');
        item.removeClass('on');
    });
    item.mouseover(function() {
        var ind = $(this).index();
        $(this).addClass('on').siblings('li').removeClass('on');
        info.eq(ind).removeClass('d_n').siblings('.item').addClass('d_n');
    });
})();



//服务商后台-头部

if ($('.provider_header').size() > 0) {
    function set_jd_reset() {
        var btn = $('.set_on_off>a.button')
        var data_id = Number(btn.attr('data-id'));
        if (data_id == 1) {
            btn.addClass('on');
        } else if (data_id == 0) {
            btn.removeClass('on');
        }
        btn.click(function() {
            var obj = $(this);
            var url = 'index.php?r=provider/switch';
            //url = 'test.php';
            $.get(url, function(data) {
                var data_new = Number(data);
                if (data_new == 0) {
                    obj.removeClass('on');
                } else if (data_new == 1) {
                    obj.addClass('on');
                }
            })
        });
    };

    set_jd_reset();

    $('.setting').mouseover(function() {
        $(this).addClass('on');
    }).mouseout(function() {
        $(this).removeClass('on');
    });
}

//服务商公告

if ($('.announcement').size() > 0) {
    if ($.cookie('viewed') == undefined) {
        $.cookie('viewed', 'no', {
            expires: 1
        });
    }
    if ($.cookie('viewed') == 'no') {
        $('.announcement').addClass('on');
        $.cookie('viewed', 'yes', {
            expires: 1
        });
    }
    $('.announcement').mouseover(function() {
        $(this).addClass('on');
    }).mouseout(function() {
        $(this).removeClass('on');
    });
    $('.announcement .close').click(function() {
        $(this).parents('.announcement').removeClass('on');
    })
}



//选择区域

function address_cgkc() {
    if ($('#address_cgkc').size() > 0) {
        var address_box = $('#address_cgkc .content_address');
        var close = $('#address_cgkc .close');
        var filter_obj = $('#address_cgkc ul.filter');
        var button = $('#address_cgkc .address_button');
        var zhichi = $('#address_cgkc .address_zhichi');
        var address = $('#address_cgkc');
        var title_item = $('#address_cgkc .title .item');
        var province_button;
        var view_addr = $('#address_cgkc #view_addr');
        address.hover(function() {
            $(this).addClass('on');
            button.addClass('on');
            close.removeClass('d_n');
        }, function() {
            $(this).removeClass('on');
            button.removeClass('on');
            close.addClass('d_n');
        });
        close.click(function() {
            address.mouseout();
        });

        title_item.click(function() {
            $(this).addClass('on').siblings('.item').removeClass('on');
        });


        //title相关操作

        function item_title() {
            var pid = title_item.parent().attr('province-id');
            var cid = title_item.parent().attr('city-id');
            var cyid = title_item.parent().attr('county-id');
            title_item.eq(0).click(function() {
                province_html = get_province();
                address_box.html(province_html);
                ini_click();
            }).click();
            //自动初始化
            address_box.find('.province_item').each(function() {
                var data = $(this).attr('data-id');
                if (data == pid) {
                    $(this).find('a').click();
                }
            });
            title_item.eq(1).click(function() {
                var city_html = get_city(pid);
                address_box.html(city_html);
                ini_click();
            }).click();
            //自动初始化
            address_box.find('.city_item').each(function() {
                var data = $(this).attr('data-id');
                if (data == cid) {
                    $(this).find('a').click();
                }
            });
            title_item.eq(2).click(function() {
                var county_html = get_county(pid, cid);
                address_box.html(county_html);
                ini_click();
            }).click();
            //自动初始化
            address_box.find('.county_item').each(function() {
                var data = $(this).attr('data-id');
                if (data == cyid) {
                    var county_name = $(this).text();
                    if (view_addr.find('span.county').size() > 0) {
                        view_addr.find('span.county').html(county_name);
                    } else {
                        view_addr.append(' - ' + '<span class="county">' + county_name + '</span>');
                    }
                    title_item.eq(2).find('.txt').text(county_name);
                }
            });
        }

        item_title();


        //为地址更新事件

        function ini_click() {
            var province_button = $('#address_cgkc .content_address .province_item');
            var city_button = $('#address_cgkc .content_address .city_item');
            var county_button = $('#address_cgkc .content_address .county_item');
            province_click_bind(province_button);
            city_click_bind(city_button);
            county_click_bind(county_button);
        }


        //为省份添加事件

        function province_click_bind(province_button) {
            if ($('.province_item').size() > 0) {
                province_button.find('a').click(function() {
                    var pid = $(this).parent('.item').attr('data-id');
                    var province_name = $(this).text();
                    var city_html = get_city(pid);
                    address_box.html(city_html);
                    var city_button = $('#address_cgkc .content_address .city_item');
                    var city_name_top = city_button.eq(0).text();
                    var cid = city_button.eq(0).attr('data-id');
                    var county_html = get_county(pid, cid);
                    var county_name_top = $(county_html).eq(0).text();
                    var cyid = $(county_html).eq(0).attr('data-id');
                    city_click_bind(city_button);
                    view_addr.html('');
                    view_addr.append('<span class="province">' + province_name + '</span>');
                    title_item.eq(0).find('.txt').text(province_name);
                    title_item.eq(1).addClass('on').siblings('.item').removeClass('on');
                    title_item.eq(1).find('.txt').text(city_name_top);
                    title_item.eq(2).find('.txt').text(county_name_top);
                    title_item.parent().attr('province-id', pid);
                    title_item.parent().attr('city-id', cid);
                    title_item.parent().attr('county-id', cyid);
                });
            }
        }


        //为城市添加事件

        function city_click_bind(city_button) {
            if ($('.city_item').size() > 0) {
                city_button.find('a').click(function() {
                    var pid = $(this).parent('.item').attr('pid');
                    var cid = $(this).parent('.item').attr('data-id');
                    var city_name = $(this).parent().text();
                    var city_html = get_county(pid, cid);
                    address_box.html(city_html);
                    var county_button = $('#address_cgkc .content_address .county_item');
                    county_click_bind(county_button);
                    if (view_addr.find('span.city').size() > 0) {
                        view_addr.find('span.city').html(city_name);
                    } else {
                        view_addr.append(' - ' + '<span class="city">' + city_name + '</span>');
                    }
                    var county_html = get_county(pid, cid);
                    var county_name_top = $(county_html).eq(0).text();
                    var cyid = $(county_html).eq(0).attr('data-id');
                    title_item.eq(2).addClass('on').siblings('.item').removeClass('on');
                    title_item.eq(1).find('.txt').text(city_name);
                    title_item.eq(2).find('.txt').text(county_name_top);
                    title_item.parent().attr('province-id', pid);
                    title_item.parent().attr('city-id', cid);
                    title_item.parent().attr('county-id', cyid);
                });
            }
        }


        //为县城添加事件

        function county_click_bind(county_button) {
            if ($('.county_item').size() > 0) {
                county_button.find('a').click(function() {
                    close.click();
                    var county_name = $(this).text();
                    var cyid = $(this).parent().attr('data-id');
                    if (view_addr.find('span.county').size() > 0) {
                        view_addr.find('span.county').html(county_name);
                    } else {
                        view_addr.append(' - ' + '<span class="county">' + county_name + '</span>');
                    }
                    title_item.eq(2).find('.txt').text(county_name);
                    title_item.parent().attr('county-id', cyid);
                    var province_id = title_item.parent().attr('province-id');
                    var city_id = title_item.parent().attr('city-id');
                    var county_id = title_item.parent().attr('county-id');
                    if ($('.provider_info').size() > 0) {

                        filter_obj.find('li').each(function(ind) {
                            if ($(this).attr('province-id') == province_id && $(this).attr('city-id') == city_id && $(this).attr('county-id') == county_id) {
                                $('.shuoming>.sm').html($(this).attr('info'));
                                $('.feiyong>.fy>.num').html($(this).attr('price'));
                            }
                        });

                    } else {
                        $.post('index.php?r=api/districtChange', {
                            province: province_id,
                            city: city_id,
                            district: county_id
                        }, function(data) {
                            if (data == 'true') {
                                history.go(0);
                            }
                        });
                    }

                });
            }
        }



        function get_province() {
            var province_data = addressData.province;
            var province_html = '';
            var real = [];

            if (filter_obj.size() > 0) {
                filter_obj.find('li').each(function(ind) {
                    real[ind] = $(this).attr('province-id');
                });

                real = $.unique(real);
                $.each(real, function(a, b) {
                    var real_id = b;
                    for (var i = 0, len = province_data.length; i < len; i++) {
                        if (province_data[i]['id'] == real_id) {
                            province_html += '<div class="item fl province_item" data-id="' + province_data[i]['id'] + '" data-name="' + province_data[i]['name'] + '">' + '<a href="javascript:;">' + province_data[i]['name'] + '</a>' + '</div>';
                        }
                    }
                });

            } else {
                for (var i = 0, len = province_data.length; i < len; i++) {
                    province_html += '<div class="item fl province_item" data-id="' + province_data[i]['id'] + '" data-name="' + province_data[i]['name'] + '">' + '<a href="javascript:;">' + province_data[i]['name'] + '</a>' + '</div>';
                }
            }
            return province_html;
        }

        function get_city(pid) {
            var city;
            var city_html = '';
            var province = addressData.province;
            var real = [];
            for (var i = 0, plen = province.length; i < plen; i++) {
                if (province[i]['id'] == pid) {
                    city = province[i]['city'];
                    break;
                }
            }

            if (filter_obj.size() > 0) {
                filter_obj.find('li').each(function(ind) {
                    real[ind] = $(this).attr('city-id');
                });

                real = $.unique(real);
                $.each(real, function(a, b) {
                    var real_id = b;
                    for (var j = 0, cylen = city.length; j < cylen; j++) {
                        if (city[j]['id'] == real_id) {
                            //alert(real_id);
                            city_html += '<div class="item fl city_item" data-id="' + city[j]['id'] + '" data-name="' + city[j]['name'] + '" title="' + city[j]['name'] + '"pid="' + pid + '">' + '<a href="javascript:;">' + city[j]['name'] + '</a>' + '</div>';
                        }

                    }
                });

            } else {
                for (var j = 0, clen = city.length; j < clen; j++) {
                    city_html += '<div class="item fl city_item" data-id="' + city[j]['id'] + '" data-name="' + city[j]['name'] + '" title="' + city[j]['name'] + '"pid="' + pid + '">' + '<a href="javascript:;">' + city[j]['name'] + '</a>' + '</div>';
                }
            }

            return city_html;
        }


        function get_county(pid, cid) {
            var city;
            var county;
            var county_html = '';
            var province = addressData.province;
            for (var i = 0, plen = province.length; i < plen; i++) {
                if (province[i]['id'] == pid) {
                    city = province[i]['city'];
                    break;
                }
            }
            for (var i = 0, clen = city.length; i < clen; i++) {
                if (city[i]['id'] == cid) {
                    county = city[i]['county'];
                    break;
                }
            }

            if (filter_obj.size() > 0) {
                filter_obj.find('li').each(function(ind) {
                    //filter_obj[ind] = $(this).attr('county-id');
                    var real_id = $(this).attr('county-id');
                    for (var j = 0, cylen = county.length; j < cylen; j++) {
                        if (county[j]['id'] == real_id) {
                            //alert(real_id);
                            county_html += '<div class="item fl county_item" data-id="' + county[j]['id'] + '" data-name="' + county[j]['name'] + '" title="' + county[j]['name'] + '">' + '<a href="javascript:;">' + county[j]['name'] + '</a>' + '</div>';
                        }

                    }
                });

            } else {
                for (var j = 0, cylen = county.length; j < cylen; j++) {
                    county_html += '<div class="item fl county_item" data-id="' + county[j]['id'] + '" data-name="' + county[j]['name'] + '" title="' + county[j]['name'] + '">' + '<a href="javascript:;">' + county[j]['name'] + '</a>' + '</div>';
                }
            }
            return county_html;
        }

    }
}

address_cgkc();

//服务地区设置


if ($('#address_cgkc_set').size() > 0) {
    var county_obj = $('.county_box_fwdq');
    var address_box = $('#address_cgkc_set .content_address');
    var close = $('#address_cgkc_set .close');
    var button = $('#address_cgkc_set .address_button');
    var zhichi = $('#address_cgkc_set .address_zhichi');
    var address = $('#address_cgkc_set');
    var title_item = $('#address_cgkc_set .title .item');
    var province_button;
    var view_addr = $('#address_cgkc_set #view_addr');
    address.hover(function() {
        $(this).addClass('on');
        button.addClass('on');
        close.removeClass('d_n');
    }, function() {
        $(this).removeClass('on');
        button.removeClass('on');
        close.addClass('d_n');
    });
    close.click(function() {
        address.mouseout();
    });

    title_item.click(function() {
        $(this).addClass('on').siblings('.item').removeClass('on');
    });


    //title相关操作

    function item_title() {
        var pid = title_item.parent().attr('province-id');
        var cid = title_item.parent().attr('city-id');
        var cyid = title_item.parent().attr('county-id');
        title_item.eq(0).click(function() {
            province_html = get_province();
            address_box.html(province_html);
            ini_click();
        }).click();
        //自动初始化
        address_box.find('.province_item').each(function() {
            var data = $(this).attr('data-id');
            if (data == pid) {
                $(this).find('a').click();
            }
        });
        title_item.eq(1).click(function() {
            var city_html = get_city(pid);
            address_box.html(city_html);
            ini_click();
        }).click();
        //自动初始化
        address_box.find('.city_item').each(function() {
            var data = $(this).attr('data-id');
            if (data == cid) {
                $(this).find('a').click();
            }
        });
        title_item.eq(2).click(function() {
            var county_html = get_county(pid, cid);
            address_box.html(county_html);
            ini_click();
        }).click();
        //自动初始化
        address_box.find('.county_item').each(function() {
            var data = $(this).attr('data-id');
            if (data == cyid) {
                var county_name = $(this).text();
                if (view_addr.find('span.county').size() > 0) {
                    view_addr.find('span.county').html(county_name);
                } else {
                    view_addr.append(' - ' + '<span class="county">' + county_name + '</span>');
                }
                title_item.eq(2).find('.txt').text(county_name);
            }
        });
    }

    item_title();


    //为地址更新事件

    function ini_click() {
        var province_button = $('#address_cgkc_set .content_address .province_item');
        var city_button = $('#address_cgkc_set .content_address .city_item');
        var county_button = $('#address_cgkc_set .content_address .county_item');
        province_click_bind(province_button);
        city_click_bind(city_button);
    }


    //为省份添加事件

    function province_click_bind(province_button) {
        if ($('.province_item').size() > 0) {
            province_button.find('a').click(function() {
                var pid = $(this).parent('.item').attr('data-id');
                var province_name = $(this).text();
                var city_html = get_city(pid);
                address_box.html(city_html);
                var city_button = $('#address_cgkc_set .content_address .city_item');
                var city_name_top = city_button.eq(0).text();
                var cid = city_button.eq(0).attr('data-id');
                var county_html = get_county(pid, cid);
                var county_name_top = $(county_html).eq(0).text();
                var cyid = $(county_html).eq(0).attr('data-id');

                city_click_bind(city_button);
                view_addr.html('');
                view_addr.append('<span class="province">' + province_name + '</span>');
                title_item.eq(0).find('.txt').text(province_name);
                title_item.eq(1).addClass('on').siblings('.item').removeClass('on');
                title_item.eq(1).find('.txt').text(city_name_top);
                title_item.eq(2).find('.txt').text(county_name_top);
                title_item.parent().attr('province-id', pid);
                title_item.parent().attr('city-id', cid);
                title_item.parent().attr('county-id', cyid);
            });
        }
    }


    //为城市添加事件

    function city_click_bind(city_button) {
        if ($('.city_item').size() > 0) {
            city_button.find('a').click(function() {
                var pid = $(this).parent('.item').attr('pid');
                var cid = $(this).parent('.item').attr('data-id');
                var county_html = get_county(pid, cid);
                var city_name = $(this).text();
                if (view_addr.find('span.city').size() > 0) {
                    view_addr.find('span.city').html(city_name);
                } else {
                    view_addr.append(' - ' + '<span class="city">' + city_name + '</span>');
                }
                close.click();
                county_obj.html(county_html);
                county_obj.find('input.checkbox').iCheck({
                    checkboxClass: 'icheckbox_square-blue',
                    radioClass: 'iradio_square-blue',
                    increaseArea: '20%' // optional
                });
                county_obj.find('.county_item').click(function() {
                    var data_id = $(this).attr('data-id');
                    if ($(this).hasClass('on')) {
                        var item_size = $('.current_address').find('.info>.item').length;
                        if (item_size == 1) {
                            $('.current_address').addClass('d_n');
                        }

                        $(this).find('input').iCheck('uncheck');
                        var county_selected = $(this).text();
                        $('.current_address .info').find('.item').each(function() {
                            if ($(this).attr('data-id') == data_id) {
                                $(this).remove();
                            }
                        });
                    } else {
                        $(this).find('input').iCheck('check');
                        var county_selected = $(this).text();
                        var province_name = title_item.eq(0).text();
                        province_name = $.trim(province_name);
                        city_name = $.trim(city_name);
                        county_selected = $.trim(county_selected);
                        $('.current_address').removeClass('d_n');
                        $('.current_address .info').append('<div class="item fl" province-id="' + pid + '" city-id="' + cid + '" data-id="' + data_id + '">' + province_name + '-' + city_name + '-' + county_selected + '</div>');
                    }
                    $(this).toggleClass('on');
                    check_next();
                });
                county_obj.find('.county_item input').on('ifClicked', function() {
                    $(this).parents('.county_item').click();
                });

                $('.current_address .info').find('.item').each(function() {
                    var data_id_checked = $(this).attr('data-id');
                    $('.county_box_fwdq .item').each(function() {
                        var data_id = $(this).attr('data-id');
                        if (data_id == data_id_checked) {
                            $(this).addClass('on');
                            $(this).find('input').iCheck('check');
                        }
                    });
                });

            });
        }
    }

    function check_next() {
        var next_step = $('.next_step a');
        if ($('.current_address>.info>.item').size() > 0) {
            next_step.addClass('ok').css('background', '#18c877');
        } else {
            next_step.removeClass('ok').css('background', '#ccc');
        }
    }

    check_next();

    function get_province() {
        var province_data = addressData.province;
        var province_html = '';
        for (var i = 0, len = province_data.length; i < len; i++) {
            province_html += '<div class="item fl province_item" data-id="' + province_data[i]['id'] + '" data-name="' + province_data[i]['name'] + '">' + '<a href="javascript:;">' + province_data[i]['name'] + '</a>' + '</div>';
        }
        return province_html;
    }

    function get_city(pid) {
        var city;
        var city_html = '';
        var province = addressData.province;
        for (var i = 0, plen = province.length; i < plen; i++) {
            if (province[i]['id'] == pid) {
                city = province[i]['city'];
                break;
            }
        }
        for (var j = 0, clen = city.length; j < clen; j++) {
            city_html += '<div class="item fl city_item" data-id="' + city[j]['id'] + '" data-name="' + city[j]['name'] + '" title="' + city[j]['name'] + '"pid="' + pid + '">' + '<a href="javascript:;">' + city[j]['name'] + '</a>' + '</div>';
        }
        return city_html;
    }


    function get_county(pid, cid) {
        var city;
        var county;
        var county_html = '';
        var province = addressData.province;
        for (var i = 0, plen = province.length; i < plen; i++) {
            if (province[i]['id'] == pid) {
                city = province[i]['city'];
                break;
            }
        }
        for (var i = 0, clen = city.length; i < clen; i++) {
            if (city[i]['id'] == cid) {
                county = city[i]['county'];
                break;
            }
        }
        for (var j = 0, cylen = county.length; j < cylen; j++) {
            county_html += '<div class="item fl county_item" data-id="' + county[j]['id'] + '" data-name="' + county[j]['name'] + '" title="' + county[j]['name'] + '">' + '<input type="checkbox" class="checkbox" name="' + county[j]['id'] + '" />' + '<a href="javascript:;">' + county[j]['name'] + '</a>' + '</div>';
        }
        return county_html;
    }

}



//在地址中，把字母转化为文字

function address_to_text(p_id, c_id, d_id) {
    var province = addressData.province;
    var city;
    var county;
    var province_text;
    var city_text;
    var county_text;
    var return_arr = [];
    $.each(province, function(i, n) {
        if (n['id'] == p_id) {
            province_text = n['name'];
            city = n['city'];
            return false;
        }
    });

    $.each(city, function(i, n) {
        if (n['id'] == c_id) {
            city_text = n['name'];
            county = n['county'];
            return false;
        }
    });

    $.each(county, function(i, n) {
        if (n['id'] == d_id) {
            county_text = n['name'];
            return false;
        }
    });
    return_arr = [province_text, city_text, county_text];

    return return_arr;

}



if ($('.address_string').size() > 0) {
    (function() {
        var obj = $('.address_string');
        var p_id = obj.attr('data-province');
        var c_id = obj.attr('data-city');
        var d_id = obj.attr('data-county');
        var arr = address_to_text(p_id, c_id, d_id);
        var data = arr[0] + '-' + arr[1] + '-' + arr[2];
        $('<span>').append(data).insertAfter(obj);
    })();
}



//在地址中，把数字转化为文字

function address_to_text2(p_id, c_id, d_id) {
    var addr = ChineseDistricts[86];
    var province = [];
    var city = ChineseDistricts[p_id];
    var county = ChineseDistricts[c_id];
    var province_text;
    var city_text = ChineseDistricts[p_id][c_id];
    var county_text = ChineseDistricts[c_id][d_id];
    var return_arr = [];

    $.each(addr, function(i, n) {
        $.each(n, function(a, b) {
            province.push(b);
        });
    });

    $.each(province, function(i, n) {
        if (n['code'] == p_id) {
            province_text = n['address'];
            return false;
        }
    });


    return_arr = [province_text, city_text, county_text];

    return return_arr;
}



if ($('.address_string2').size() > 0) {
    (function() {
        var obj = $('.address_string2');
        obj.each(function() {
            var p_id = $(this).attr('data-province');
            var c_id = $(this).attr('data-city');
            var d_id = $(this).attr('data-county');
            var arr = address_to_text2(p_id, c_id, d_id);
            var data = arr[0] + '-' + arr[1] + '-' + arr[2];
            $('<span>').append(data).insertAfter($(this));
        });
    })();
}



//us_after

(function() {
    if ($('.us_after').size() > 0) {
        var obj = $('.us_after');
        obj.hover(function() {
            $(this).addClass('on');
        }, function() {
            $(this).removeClass('on');
        })
    }
})();



//menu_module

if ($('.menu_module').size() > 0) {
    (function() {
        var module = $('.menu_module .module');
        var wrap = $('.menu_module .wrap');
        var li = module.find('li');
        var module_zhichi = $('.menu_module .module_zhichi');
        var special = $('.menu_module .special');
        li.last().find('div.line').remove();

        special.hover(function() {
            $(this).addClass('on');
        }, function() {
            $(this).removeClass('on');
        });

        wrap.hover(function() {
            module_zhichi.removeClass('d_n').animate({
                width: '674px'
            }, 200);
        }, function() {
            module_zhichi.stop().css({
                width: '0'
            }).addClass('d_n');
            li.removeClass('on');
        });


        li.mouseover(function() {
            var ind = $(this).index();
            $(this).addClass('on').siblings('li').removeClass('on');
            var html_zhichi = $(this).find('.zhichi').html()+'<div class="bg_menu_module"></div>'+'<a href="javascript:;" class="service_now" onclick="openZoosUrl(\'chatwin\');">马上咨询</a>';
            module_zhichi.html(html_zhichi);
            module_zhichi.find('.second>.item:last').css('border', '0');
            var zt = module_zhichi.find('.zts>.zt');


            (function() {
                var more_zhichi = module_zhichi.find('.more_zhichi');
                more_zhichi.each(function() {
                    var more = $(this).prev('.more');
                    //为more_zhichi-定位
                    var top = more.offset().top - module_zhichi.offset().top + 28;
                    var zhichi = $(this);
                    $(this).css('top', top);
                    $(this).css('padding-top', '16px');
                    var i_left = more.offset().left - module_zhichi.offset().left - more.outerWidth() / 2 - 50;
                    var zhichi_main = $(this).children('.zhichi_main');
                    zhichi_main.children('i').css('left', i_left);
                    //为more添加hover事件
                    var more_wrap = more.parent('.more_wrap');
                    more_wrap.mouseover(function() {
                        $(this).find('.more_zhichi').removeClass('d_n');
                        $(this).find('.more').addClass('on');
                    });
                    more_wrap.mouseout(function() {
                        $(this).find('.more_zhichi').addClass('d_n');
                        $(this).find('.more').removeClass('on');
                    });
                    //为more_zhichi添加类别滑动

                    (function() {
                        var btn = zhichi.find('.btns>.btn');
                        btn.hover(function() {
                            var zt = $(this).parent('.btns').next('.zts').children('.zt');
                            var index = $(this).index();
                            $(this).addClass('on').siblings('.btn').removeClass('on');
                            zt.eq(index).removeClass('d_n').siblings('.zt').addClass('d_n');
                        });
                    })();
                    //第一个类别被选中
                    (function() {
                        zhichi.find('.btns>.btn').eq(0).addClass('on');
                        zhichi.find('.zts>.zt').eq(0).removeClass('d_n');
                    })();

                });
            })();
            zt.each(function() {
                var zt_this = $(this);
                var item = zt_this.children('a');
                item.wrap('<td></td>');
                var td = zt_this.find('td');
                var td_size = td.size();
                var tr = $('<tr/>');
                var tr_size = Math.ceil(td_size / 4);

                for (var i = 0; i < tr_size; i++) {
                    $('<tr/>').appendTo(zt_this);
                }
                td.each(function(ind) {
                    var xl = Math.floor(ind / 4);
                    $(this).appendTo(zt_this.find('tr').eq(xl));
                });

                tr = zt_this.find('tr');

                tr.each(function() {
                    var td_size = $(this).find('td').size();
                    if (td_size < 4) {
                        var less_len = 4 - td_size;
                        for (var i = 0; i < less_len; i++) {
                            $('<td/>').appendTo($(this));
                        }
                    }
                });

                tr.last().find('td').addClass('no_border');

                tr.wrapAll('<table></table>');



            });
        });


    })();
}


//search



if ($('.header .search').size() > 0) {
    var obj = $('.header .search');
    var btn = obj.find('.submit_box');
    btn.hover(function() {
        $(this).addClass('on');
    }, function() {
        $(this).removeClass('on');
    });
    btn.click(function() {
        var val = obj.find('input.text').val();
        if (val != '') {
            $('form.search_f').submit();
        }
    })
}

// 登录后的下拉菜单 link_dh



//内页分类菜单展开收起



if ($('.page_module').length > 0) {
    (function() {
        var btn = $('.menu_wrap .btn');
        var iconfont = btn.find('.iconfont');
        var menu = $('.menu_module');
        var module = $('.menu_module .module');
        var wrap = $('.menu_module .wrap');
        var li = module.find('li');

        btn.hover(function() {
            $('.page_module').addClass('on');
            btn.addClass('on');
            li.eq(0).mouseover();
            iconfont.rotate({
                animateTo: 180
            });
        }, function() {
            $('.page_module').removeClass('on');
            iconfont.rotate({
                animateTo: 0
            });
            btn.removeClass('on');
        });


        var module_zhichi = $('.menu_module .module_zhichi');
        menu.hover(function() {
            $('.page_module').addClass('on');
            btn.addClass('on');
            iconfont.rotate({
                animateTo: 180
            });
        }, function() {
            $('.page_module').removeClass('on');
            btn.removeClass('on');
            iconfont.rotate({
                animateTo: 0
            });
        });

        if ($('.index_box').length > 0) {
            menu.css('display', 'block');
        }

    })();



}



//内页搜索展开收缩

if ($('.header_son').size() > 0) {
    (function() {
        var obj = $('.header_son');
        var search_btn = obj.find('.search_wrap');
        var search_zhichi = obj.find('.search');
        var input = search_zhichi.find('input.text');
        var right_value = 0;
        if (obj.find('.user').length > 0) {
            right_value = obj.find('.user').outerWidth(true) + obj.find('.R.fr').outerWidth();
        } else {
            right_value = obj.find('.us_dh').outerWidth(true) + obj.find('.R.fr').outerWidth();
        }
        search_btn.css('right', right_value).css('visibility', 'visible');
        search_btn.click(function() {
            $(this).find('.search').removeClass('d_n');
            input.animate({
                width: '260px'
            }, 300);
            search_zhichi.animate({
                width: '360px'
            }, 300);
            input.focus();
        });
        input.blur(function() {

            input.animate({
                width: '1px'
            }, 100);
            search_zhichi.animate({
                width: '100px'
            }, 100, function() {
                search_zhichi.addClass('d_n');
            });
        })
    })();

}



//检测是否第一次登录，弹出优惠券窗口;

(function() {
    if ($('.coupon_first_zhichi.show_box').size() > 0) {
        if ($.cookie('coupon') == 'yes') {
            $.removeCookie('coupon', {
                path: '/'
            });
            var show_box = $('.coupon_first_zhichi.show_box');
            var btn = show_box.find('#get_coupon');
            var close = show_box.find('.button_close');
            //	show_window(show_box);
            //	close.off();
            close.click(function() {
                var r = confirm('您要放弃领取资格吗？');
                if (r == false) {
                    return false;
                } else {
                    var code = show_box.find('.code');
                    var cover = show_box.find('.cover');
                    code.hide();
                    cover.hide();
                    show_box.css('display', 'none');
                }
            });
            btn.click(function() {
                var url = './index.php?r=user/getCoupon';
                //url = 'test.php';
                $.post(url, function(data) {
                    data = JSON.parse(data);
                    if (data.code == 0) {
                        tip_suc('优惠券领取成功');
                        btn.off();
                        setTimeout(function() {
                            window.history.go(0);
                        }, 1200);
                    } else {
                        tip_fan('出错了，请重试');
                    }
                });
            });
        } else {
            $.removeCookie('coupon', {
                path: '/'
            });
        }
    }

})();



//红包悬浮在右侧

(function() {
    if ($('.coupon_right_wrap').size() > 0) {
        var box = $('.coupon_right_wrap');
        var close = box.find('a.close_btn');
        close.click(function() {
            box.remove();
        });
    }
})();



//广东省会计师事务所计算器

(function() {
    if ($.exist('.calculator_wrap')) {
        var box = $('.calculator_wrap');
        var btn = box.children('.btn');

        btn.click(function() {
            var html = box.find('.support').html();
            var support = $.show_window(html, 'calculator');
            var option = support.find('.table .select>.option');
            var op_html = '';
            var btn_go = support.find('.btn.go');
            var btn_reset = support.find('.btn.reset');
            var result = support.find('.result');

            var zcze = support.find('input.zcze.text');
            var zsr = support.find('input.zsr.text');
            var yzje = support.find('input.yzje.text');

            var tr = support.find('.table tr');

            option.each(function(ind) {
                var val = $.trim($(this).text());
                op_html = op_html + '<option value="' + ind + '">' + val + '</option>';
            });

            var sec_html = '<select>' + op_html + '</select>';

            bind_number(support);

            support.find('.table .select').removeClass('d_n').html(sec_html);

            var sec = support.find('.select>select');

            sec.drop_down_obj();

            sec.change(function() {
                var val = $(this).val();
                go_sec(val);
            });

            function go_sec(val) {
                if (val == 0) {
                    tr.filter('.nb').removeClass('d_n');
                    tr.filter('.yz').addClass('d_n');
                } else if (val == 1) {
                    tr.filter('.yz').removeClass('d_n');
                    tr.filter('.nb').addClass('d_n');
                }
            }

            go_sec(0);

            btn_go.click(function() {
                var type;
                support.find('tr:not(.d_n)').find('input[filter=number]').blur();
                if (support.find('input[ok=no]').length > 0) {
                    return false;
                }

                if (sec.val() == 0) {
                    var zcze_val = Number(zcze.val());
                    var zsr_val = Number(zsr.val());
                    type = 'nb';
                    var result_nb = $.calculator(zcze_val, zsr_val, type);
                    result.html(result_nb);
                } else if (sec.val() == 1) {
                    type = 'yz';
                    var yzje_val = Number(yzje.val());
                    var result_yz = $.calculator(yzje_val, 0, type);
                    result.html(result_yz);
                }

            });

            btn_reset.click(function() {
                result.html('0.00');
                zcze.val('');
                zsr.val('');
                yzje.val('');
            });
        });


        //数字限制

        function bind_number(box) {
            var input = box.find('input[filter=number]');
            input.each(function() {
                $(this).blur(function() {
                    var min = Number($(this).attr('min-num'));
                    var val = $(this).val();
                    var ok = $.is_number(val);
                    var tip = $(this).parents('td').prev('td').find('span').text();
                    tip = $.trim(tip);


                    if (min == undefined || min == '') {
                        min = 0;
                    }
                    if (val == '') {
                        $.tip_fan(tip + '为必填项');
                        $(this).attr('ok', 'no');
                        $(this).css('border-color', '#ff2f00');
                    } else if (!ok) {
                        $.tip_fan(tip + '为数字');
                        $(this).attr('ok', 'no');
                        $(this).css('border-color', '#ff2f00');
                    } else if (val < min) {
                        $.tip_fan(tip + '不可少于' + min);
                        $(this).attr('ok', 'no');
                        $(this).css('border-color', '#ff2f00');
                    } else {
                        $(this).attr('ok', 'yes');
                        $(this).css('border-color', '#e0e5ec');
                    }
                });

                $(this).focus(function(event) {
                    var min = Number($(this).attr('min-num'));
                    var val = Number($(this).val());
                    var ok = $.is_number(val);
                    if (val > min && ok) {
                        $(this).attr('ok', 'yes');
                        $(this).css('border', '1px solid #e0e5ec');
                    }

                });
                $(this).keyup(function(event) {
                    var min = Number($(this).attr('min-num'));
                    var val = Number($(this).val());
                    var ok = $.is_number(val);
                    if (val > min && ok) {
                        $(this).attr('ok', 'yes');
                        $(this).css('border', '1px solid #e0e5ec');
                    }
                });
            });

        }



    }
})();



//免费电话

(function() {
    var btn = $('.mfdh');

    if (btn.length > 0) {

        var zhichi = $('.mfdh_zhichi');
        var html = zhichi.html();
        btn.click(function() {
            zhichi.html(html);
            var service_id = $(this).attr('service_id');
            show_window(zhichi);
            zhichi.data('service_id', service_id);
            go(zhichi, 0);
            bind_event(zhichi);
        });
    }



    //状态切换

    function go(zhichi, num) {
        var menu = zhichi.find('.progress>.item');
        var con = zhichi.find('.status>.item');
        menu.eq(num).addClass('on').siblings('.item').removeClass('on');
        con.eq(num).removeClass('d_n').siblings('.item').addClass('d_n');

    }


    function bind_event(zhichi) {
        var menu = zhichi.find('.progress>.item');
        if (menu.filter('.on').index() != 0) {
            return false;
        }
        var btnSendCode = zhichi.find('#btnSendCode');
        var phone = zhichi.find('input.text.phone');
        var yzm = zhichi.find('input.text.yzm');
        var phone_ok = false;
        var yzm_ok = false;
        var start_consult = zhichi.find('.start_consult.btn');

        start_consult.click(function() {
            check_phone();
            check_yzm();
            if (phone_ok && yzm_ok) {
                var url = './index.php?r=provider/sxhujiao';
                var service_id = zhichi.data('service_id');
                $.post(url, {
                    phone: phone.val(),
                    yzm: yzm.val(),
                    service_id: service_id
                }, function(data) {
                    data = JSON.parse(data);
                    if (data.code == 0) {
                        go(zhichi, 3);
                        setTimeout(function() {
                            $('.button_close').click();
                        }, 20000);
                    } else {
                        tip_fan(data.msg);
                    }
                });
            }

        });

        btnSendCode.click(function() {
            var btn = $(this);
            var count = 60;
            var url = './index.php?r=provider/sxcode';
            check_phone();
            if (!phone_ok) {
                tip_fan('请输入正确的手机号码！');
            } else {
                $.CountDownP(phone, btn, count, url);
            }
        });

        function check_phone() {
            phone_ok = !(phone.checkPhone());
            if (!phone_ok) {
                tip_fan('请输入正确的手机号码！');
                phone_ok = false;
            }
        }

        function check_yzm() {
            yzm_ok = !(yzm.val().length < 6);
            if (!yzm_ok) {
                tip_fan('请输入正确的验证码！');
                yzm_ok = false;
            }
        }


    }


})();



//toolbar



(function() {
    if ($.exist('.toolbarbox')) {
        var rotate_deg = 0; //回正 回到0度
        var rotate_angle = 30; //旋转度数 30度
        var rotate_deg_step = 5; //每次旋转角度，能够被_angle整除
        var rotate_duration = 1; //每次旋转时间
        var rotate_count = 0; //初始旋转次数
        var rotate_count_max = 6; //最大旋转次数
        var rotate_timer = null;
        var rotate_stop_time = 0;
        var rotate_stop_max_time = 500; //停止时间3秒

        function rotate_rotate(item) {
            if (rotate_count == rotate_count_max) {
                if (rotate_deg == 0) {
                    rotate_stop_time = rotate_stop_time + rotate_duration;
                    if (rotate_stop_time == rotate_stop_max_time) {
                        rotate_stop_time = 0;
                        rotate_count = 0;
                    }
                    return;
                }
                rotate_deg = rotate_deg + rotate_deg_step;
                $("#" + item).css("transform", "rotate(" + rotate_deg + "deg)");
                return;
            }

            rotate_deg = rotate_deg + rotate_deg_step;
            if (rotate_deg == rotate_angle || rotate_deg == -rotate_angle) {
                rotate_count = rotate_count + 1;
                rotate_deg_step = -rotate_deg_step;
            }
            $("#" + item).css("transform", "rotate(" + rotate_deg + "deg)");
        }

        function rotate_start(item) {
            rotate_timer = setInterval(function() {
                rotate_rotate(item);
            }, rotate_duration);
        }

        function rotate_stop() {
            clearInterval(rotate_timer);
        }

        rotate_start("msg");

        //tips-自动弹窗

        (function() {
            $('.tips.layer').remove();
            $('<div class="tips layer d_n"><div class="close"></div></div>').appendTo('body');

            var tips = $('.tips.layer');
            setTimeout(function() {
                tips.removeClass('d_n');
            }, 2000);
            var tt = setTimeout(function() {
                $('.toolbarbox .msg').click();
                tips.remove();
            }, 4000);
            tips.find('.close').click(function() {
                tips.remove();
                clearTimeout(tt);
            });

        })();
    }



})();